package com.guoranhao.web.interceptor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Description: 校验token有效性
 * Copyright (c) Department of Research and Development/Beijing
 * All Rights Reserved.
 * @version 1.0  2016年9月2日 上午10:35:26  by 陆怀彬（luhb@cloud-young.com）陆怀彬
 */
@Component
public class AuthenticationInterceptor extends HandlerInterceptorAdapter {
	
	private static final Logger logger = LoggerFactory.getLogger(AuthenticationInterceptor.class);

    @Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//		String requestURI = request.getRequestURI();
//		String accessToken = request.getHeader(HeaderParams.HEADER_KEY_ACCESSTOKEN);
//		if (StringUtils.isNotBlank(accessToken)) {
//			return true;
//		}
//		LogUtil.info(logger, "token is null  accessToken={0},uri={1}", accessToken, requestURI);
//		response.setContentType("application/json");
//		String object2Json = JsonUtil.Object2Json(new MessageVo<>(false, AuthErrorCodeEnum.COMMON_ERROR_160019.getCode(), AuthErrorCodeEnum.COMMON_ERROR_160019.getMsg()));
//		response.getWriter().write(object2Json);
//		return false;
		return true;
	}

}
